export default {
  install(Vue) {
    Vue.directive("preventReClicks", {
      inserted(el, binding) {
        el.addEventListener("click", () => {
          if (!el.disabled) {
            el.disabled = true;
            let backgroundcolor = el.style.backgroundColor;
            el.style.backgroundColor = "#909399";
            setTimeout(() => {
              el.disabled = false;
              el.style.backgroundColor = backgroundcolor;
            }, binding.value || 400);
          }
        });
      },
    });
  },
};
